//
//  SearchView.h
//  MobileZIPCodes
//
//  Created by Andreas Schwelling on 29.11.07.
//	http://www.andi.de/zipcodes/
// 
//  Released under the GNU General Public License.
//  See LICENSE for details.
//
//  Use at your own risk.
//


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UITransitionView.h>
#import <UIKit/UIPreferencesTable.h>
#import <UIKit/UISectionList.h>
#import <UIKit/UISegmentedControl.h>
#import <UIKit/UISwitchControl.h>
#import <UIKit/UIPreferencesTextTableCell.h>
#import <UIKit/UIButtonBar.h>
#import <UIKit/UIProgressIndicator.h>
#import <UIKit/UIFrameAnimation.h>
#import <WebCore/WebFontCache.h>

#import "DataManager.h"
#import "ResultView.h"


@interface UIRightTextLabel : UITextLabel {
	float 	_savedRightEdgeX;
	BOOL	_sizedtofit_flag;
}

-(void)setFrame:(CGRect)frame;
-(void)setText:(NSString*)text;
-(void)realignText;

@end



@interface SearchChooseView: UIView {
	CGRect				_rect;
	UISectionList		*_sectionList;
	UITable				*_table;
	NSMutableArray		*_tableCells;
	NSMutableArray		*_tableHeaders;
	id					_delegate;
	UIView				*_prevView;
	NSString			*_city;
	NSMutableArray		*_stateArr;
	
}

-(id)initWithFrame:(CGRect)frame;
-(void)setDelegate:(id)del;
-(void)setPrevView:(UIView*)pv;
-(UIView*)getPrevView;
-(void)setCity:(NSString*)city;

@end



@interface SearchCountryView: UIView {
	
	CGRect				_rect;
	UITransitionView	*_transitionView;
	UIView				*_actualView,*_searchview;
	UIKeyboard				*_kb;
	
	UISectionList		*_sectionList;
	UITable				*_table;
	id					_delegate;
	NSMutableArray*			_tableCells;
	NSMutableArray*			_tableHeaders;
	UINavigationBar		*_navBar;
	BOOL					keyboardVisible;
	SearchChooseView		*_searchChooseView;
	BrowseDataObject		*_bdo;
	SearchNameResultView	*_searchNameResultView;
	SearchZipResultView		*_searchZipResultView;
	
}

- (id)initWithFrame:(struct CGRect)rect;
-(void)dealloc;
-(UINavigationBar*)getNavBar;
-(BrowseDataObject*)getBdo;
-(void)setDelegate:(id)del;
-(UITransitionView*)getTransitionView;
- (void) showSearchZipResult:(NSString*)searchentry withState:(NSString*) state withBdo:(BrowseDataObject*)bdo;
- (void) showSearchNameResult:(NSString*)searchentry withState:(NSString*) state withBdo:(BrowseDataObject*)bdo;
- (void) showSearchChooser:(NSString*)searchentry withBdo:(BrowseDataObject*)bdo;
-(void)keyboardReturnPressed;
- (void) clearButtonClicked;
-(void)showKeyboard;
-(void) hideKeyboard;


@end


@interface SearchField: UISearchField {
	
	
}
-(id)initWithFrame:(CGRect)frame;
- (bool)isEditing;



@end






@interface SearchView : UIView {
	SearchField				*_searchField;
	UINavigationBar			*_textView,*_navBar;
	UIProgressIndicator		*_uip;
	id						*_delegate;
	UIView					*_prevView;
	UITable					*_table;
	NSMutableArray*			_tableCells;
	NSString				*_lastText;
	NSTimer					*_inputTimer;
	
}

-(id)initWithFrame:(CGRect)rect;
-(void)dealloc;
- (void) fillTable;
- (void) showUIP:(id)p;
- (BOOL)stringContainsNumbers:(NSString *)str;
- (void) handleInput:(id)p;
-(void)clearButtonClicked;
-(void)isEdited;
-(void)setPrevView:(UIView*)pv;
-(UIView*)getPrevView;
-(UITable*)getSearchTable;
-(void)setDelegate:(id)del;
- (void) processTableSelection:(id)p;

@end
